import axios from "axios";
import {showFailToast} from 'vant';
import {RequestErrorMsg} from "@/api/requestErrorMsg.js";
let request = axios.create({
    timeout: 5000,
    baseURL: ''
})

//请求拦截器
request.interceptors.request.use(config => {
    //添加token
    // config.headers.token='token'
    return config
})

//响应拦截器

request.interceptors.response.use((respone) => {
    //todo
    return respone.data
}, (error) => {
    switch (error.response.status) {
        case 401:
            //todo
            break;
        case 403:
            //todo
            break;
        case 404:
            //todo
            break;
        case 405:
            //todo
            break;
        case 500:
            //todo
            break;
        default:
            //todo
    }
    showFailToast(RequestErrorMsg[error.response.status].name)
})

export default request
